global infile "DataMain.dta"
global outfile "$results/Table A1A"
global outfile2 "$results/Table A1B"


* Create data with alternative functional forms

use "$infile", clear

sum water if water != 0
sum water, d
display (24.28572/92.28571)^2

gen logwater01 = log(water+0.1)
gen logwater10 = log(water+10)

gen invwater01 = asinh(water*0.1)
gen invwater = asinh(water)
gen invwater10 = asinh(water*10)

egen watermh = mean(water), by(home)
egen waterm = mean(watermh), by(home)

gen waternorm = water/waterm

save "Temp", replace

drop if week2 >= 34

save "Temp2", replace


* Full data results

use "Temp", clear
reghdfe logwater10 treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = (exp(_b[treat])-1)*(water+10)
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word replace ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp", clear
reghdfe logwater treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = (exp(_b[treat])-1)*(water+1)
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp", clear
reghdfe logwater01 treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = (exp(_b[treat])-1)*(water+0.1)
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp", clear
reghdfe invwater01 treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = 10*sinh(_b[treat]+invwater01) - water
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp", clear
reghdfe invwater treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = sinh(_b[treat]+invwater) - water
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp", clear
reghdfe invwater10 treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = 0.1*sinh(_b[treat]+invwater10) - water
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp", clear
reghdfe waternorm treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = _b[treat]*waterm
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp", clear
reghdfe water treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = _b[treat]
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 


* Event sample results

use "Temp2", clear
reghdfe logwater10 treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = (exp(_b[treat])-1)*(water+10)
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile2", keep(treat) nocon 2aster dec(3) word replace ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp2", clear
reghdfe logwater treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = (exp(_b[treat])-1)*(water+1)
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile2", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp2", clear
reghdfe logwater01 treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = (exp(_b[treat])-1)*(water+0.1)
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile2", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp2", clear
reghdfe invwater01 treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = 10*sinh(_b[treat]+invwater01) - water
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile2", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp2", clear
reghdfe invwater treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = sinh(_b[treat]+invwater) - water
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile2", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp2", clear
reghdfe invwater10 treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = 0.1*sinh(_b[treat]+invwater10) - water
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile2", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp2", clear
reghdfe waternorm treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = _b[treat]*waterm
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile2", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "Temp2", clear
reghdfe water treat, absorb(datasethome datasetweek) cluster(home)
keep if treated == 1
keep if treat == 0
egen pre = mean(water), by(home)
gen effecthelp = _b[treat]
egen effect = mean(effecthelp), by(home)
duplicates drop home, force
sum pre
global prem = r(mean)
sum effect
global effectm = r(mean)
global transbeta = $effectm/$prem*100
outreg2 using "$outfile2", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 



